package com.direct.ratelimit.threshold;

import com.direct.ratelimit.action.Action;
import com.direct.ratelimit.limit.Limit;

public class Threshold {

	private final int percentage;
	private final Limit limit;
	private final Action action;

	public Threshold(int percentage, Limit limit, Action action) {
		super();
		this.percentage = percentage;
		this.limit = limit;
		this.action = action;
	}

	/**
	 * has this threshold been exceded
	 * 
	 * @param numberOfRequest
	 * @return
	 */
	protected boolean isExceeded(int numberOfRequest) {
		return numberOfRequest >= (limit.getRequestLimit() * (percentage / 100));
	}

	public int getPercentage() {
		return percentage;
	}

	public Limit getLimit() {
		return limit;
	}

	public Action getAction() {
		return action;
	}
	
	

}
